package com.backend.modules.system.service;

import com.backend.common.security.AuthContext;
import com.backend.common.utils.JwtUtils;
import com.backend.modules.system.entity.SysUser;
import lombok.RequiredArgsConstructor;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class TokenService {
    
    private final JwtUtils jwtUtils;
    
    public String generateToken(Long userId) {
        return jwtUtils.generateToken(userId);
    }
    
    public UsernamePasswordAuthenticationToken getAuthentication(String token) {
        Long userId = jwtUtils.getUserIdFromToken(token);
        return new UsernamePasswordAuthenticationToken(userId, null, null);
    }
    
    public boolean validateToken(String token) {
        return !jwtUtils.isTokenExpired(token);
    }
} 